// pages/attractionsList/attractionsList.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputValue:'',
    address:'',
    introduce:'222',
    list:"",
  },
  goPageDetails: function(e){
    //console.log(e)
    var scenicId = e.currentTarget.dataset.scenicid
    var address = this.data.address
    var imgList = e.currentTarget.dataset.image
    console.log(imgList)
    // console.log(e.currentTarget.dataset.scenicName)
    wx.navigateTo({
      url: '/pages/attractionsDetails/attractionsDetails?scenicId='+scenicId+'&address='+address+'&imglist='+imgList
      })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  bindKeyInput: function (e) {
    this.setData({
      inputValue: e.detail.value
    })
  },
  onLoad: function (options) {
    const that = this
    var address = options.address
    console.log(address)
    wx.request({
      url: 'http://120.25.151.125:8080/travel/scenic/scenicAllList',
      data:{
        address:address
      },
      method:'GET',
      header:{
        'Content-Type': 'application/json'
      },
      success: function (res) {
        var imglist1 = []
        var i = 0
        let data = res.data
        console.log(data)
        for(let item of data){
          let _imgUrl = item.imageUrl;
          item.imageUrl = _imgUrl.split(",")
        }
        //将获取到的json数据，存在名字叫list的这个数组中
        that.setData({
          address: address,
          list: data,
          //res代表success函数的事件对，data是固定的，list是数组
        })
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})